﻿using System;
using System.Collections.Generic;
using System.Text;
using FrameWork.Lib;
using FrameWork.Lib.DataObjects;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace REVISIONMAX30.DataObjects
{
    public class SourcePattern : DataObjectBase
    {
        public SourcePattern()
        {
        }

        public SourcePattern(string pValidateRegEx, string pReplaceRegEx, string pReplacement)
            : base(true)
        {

            this.ValidateRegEx = pValidateRegEx;
            this.ReplaceRegEx = pReplaceRegEx;
            this.Replacement = pReplacement;
        }

        public string ValidateRegEx { get; set; }
        public string ReplaceRegEx { get; set; }
        public string Replacement { get; set; }

        public string[] ParseFileName(string pFileName )
        {
            var t = System.IO.Path.GetFileNameWithoutExtension(pFileName);

            if (System.Text.RegularExpressions.Regex.IsMatch(t, ValidateRegEx))
            {
                return System.Text.RegularExpressions.Regex.Replace(t, ReplaceRegEx, Replacement).Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                return null;
            }
        }
    }
}
